import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/**
 *Created by Jcy
 *on 2021/9/28
 */
class NetworkType {
  ///判断是否联网
 static Future<bool> isConnected() async {
    var connectivityResult = await (Connectivity().checkConnectivity());
    return connectivityResult != ConnectivityResult.none;
  }

 static Future<int> isType() async {
    int type = 0;
    var connectivityResult = await (Connectivity().checkConnectivity());
    if (connectivityResult == ConnectivityResult.mobile) {
      // 网络类型为移动网络
      type = 0;
    } else if (connectivityResult == ConnectivityResult.wifi) {
      // 网络类型为WIFI
      type = 1;
    }
    return type;
  }
}
